$ExeDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$OpenCVDir = "D:\3trd\opencv\x64\mingw\bin"
$Snap7Dir = "D:\3trd\snap7-full-1.4.2\release\Windows\Win64"

Write-Host "qt..."
windeployqt "$ExeDir\camera.exe"

Write-Host "OpenCV..."
$opencvDlls = @("libopencv_core455.dll", "libopencv_imgproc455.dll", "libopencv_videoio455.dll", "libopencv_highgui455.dll", "libopencv_ffmpeg455.dll", "libopencv_imgcodecs455.dll")

foreach ($dll in $opencvDlls) {
    $sourcePath = "$OpenCVDir\$dll"
    Write-Host "Checking: $sourcePath"
    if (Test-Path $sourcePath) {
        Copy-Item -Path $sourcePath -Destination $ExeDir -Force
        Write-Host "Copied: $dll"
    } else {
        Write-Host "File not found: $dll"
    }
}

Write-Host "Snap7..."
$Snap7DLL = "$Snap7Dir\snap7.dll"
if (Test-Path $Snap7DLL) {
    Copy-Item -Path $Snap7DLL -Destination $ExeDir -Force
    Write-Host "Snap7 Copied!"
} else {
    Write-Host "Snap7 DLL not found!"
}

Write-Host "ok"
